<?php

/**
 * 
 */
class Acceso {

    function identificado() {
        //echo 'holas';


        $this->CI = &get_instance();
        $query = "SET time_zone = '-5:00'";
        $this->CI->db->query($query);
        
        $controllersprivados = array('privado','proyeccion');
        //redirect('inicio');

        $logueado = $this->CI->session->userdata('logged_in');
        // echo "-----$logueado=======";
        $controlador = $this->CI->router->class;
        //echo $controlador;
        if ($logueado == 'ok' && $controlador == 'login') {
            if ($this->CI->router->method == 'cerrarSesion') {
                $this->CI->session->sess_destroy();
                //$ruta='http://localhost/yachay';
                $ruta = base_url();
                redirect($ruta);
            } else {
                // $ruta='http://localhost/yachay/index.php/yachay';
                $ruta = base_url() . 'index.php/privado/inicio';
                redirect($ruta);
            }
        }
        if (in_array($controlador, $controllersprivados) && $logueado != 'ok') {
            // echo 'hihih';
            // $ruta='http://localhost/yachay';
            $ruta = base_url();
            redirect($ruta);
        }

        //$this->CI->session->sess_create();
        //echo $this->CI->session->userdata('logged_in');
        //echo $this->CI->router->method;
        //echo $this->CI->router->class;
        //echo $this->CI->session->userdata('session_id');
        //$this->CI->session->sess_destroy();
        //echo $this->CI->session->userdata('logged_in');
        //echo "next";
        //echo $this->CI->session->userdata('session_id');
        //if($this->CI->session->userdata('logged_in')==true && $this->CI->router->method == 'login') redirect('home');
        //if($this->CI->session->userdata('logged_in')!=true && $this->CI->router->method!='login' && in_array($this->CI->router->class, $controllersprivados)) redirect('inicio/index');
    }

}

?>